<cfcomponent extends="org.cfcunit.framework.TestCase">

<cffunction name="dumpvar">
  <cfargument name="var">
  <cfargument name="abort" default="true">
  <cftry>
	  <cfdump var="#var#">
	<cfcatch>
	  <cfset writeoutput(cfcatch.Message & " " & cfcatch.Detail & " " & cfcatch.TagContext[1].line & " " & cfcatch.stacktrace) />
	</cfcatch>
	</cftry>
	<cfif arguments.abort>
	  <cfabort />
	</cfif>
</cffunction>


  <cffunction name="setUp" returntype="void" access="public">
			<cfset serviceDefinitionLocation = expandPath( 'services.xml' ) />
			<cfset coldSpring = createObject( 'component', 'coldspring.beans.DefaultXmlBeanFactory').init() />
			<cfset coldSpring.loadBeansFromXmlFile("/actionpacks/cfsvn/config/cs/svnConfiguration.xml") />
      <cfset variables.cfSvnFckFacade = coldSpring.getBean('cfSvnFckFacade') />
   </cffunction>
		
	<cffunction name="replaceWithOrig">
		<cfargument name="filepath" required="true" />
		<cfif NOT fileExists(filepath&".orig")>
			<cffile action="copy" source="#filepath#" destination="#filepath#.orig" />
		<cfelse>
			<cffile action="copy" source="#filepath#.orig" destination="#filepath#" />
		</cfif>		
	</cffunction>

	<cffunction name="testShrinkImageIfNeeded_jpg" access="public" returntype="void" hint="runs an fck command.">
		<cfscript>
			var imgpath = getDirectoryFromPath(getCurrentTemplatePath()) & "goodtest.jpg";
			var backup = replaceWithOrig(imgpath);
			var results = "";
			results = variables.cfSvnFckFacade.shrinkImageIfNeeded(imgpath);
		</cfscript>
		<cfset assertComplexValue(expected="tempfile.txt",actual=results) />
	</cffunction>

	<cffunction name="testShrinkImageIfNeeded_gif" access="public" returntype="void" hint="runs an fck command.">
		<cfscript>
			var imgpath = getDirectoryFromPath(getCurrentTemplatePath()) & "clown.gif";
			var backup = replaceWithOrig(imgpath);
			var results = "";
			results = variables.cfSvnFckFacade.shrinkImageIfNeeded(imgpath,200,200);
		</cfscript>
		<cfdump var="wee"><cfabort />

		<cfset assertComplexValue(expected="tempfile.txt",actual=results) />
	</cffunction>
			
</cfcomponent>